<template>
  <mu-dialog transition="slide-right" fullscreen :open.sync="openFullscreen">
    <div class="p-box">
      <div class="p-header">
        <mu-appbar color="primary" class="lan-header">
          <mu-button icon slot="left" @click="close">
            <i class="iconfont angle-left iconangle-left"></i>
            <span class="lan-header-back">返回</span>
          </mu-button>选择区域
        </mu-appbar>
      </div>
      <div class="p-content" style="background:#fff">
        <mTree
          v-show="tree.data.length"
          :data="tree.data"
          :props="tree.defaultProps"
          :clickableConditions="tree.clickableConditions"
          @click="selected"
        ></mTree>
        <NoData v-if="!tree.data.length&&!tree.loading" style="height:100%" />
      </div>
    </div>
  </mu-dialog>
</template>
<script>
import mTree from "@/tree/mTree";
export default {
  name: "dialogAddTask",
  components: {
    mTree
  },
  props: ["projectId"],
  data() {
    return {
      openFullscreen: false,
      tree: {
        loading: false,

        defaultProps: {
          id: "id",
          name: "name",
          children: "children"
        },
        clickableConditions: {
          all: {
            //所有的是否可以点击
            enable: true
          }
        },
        data: []
      }
    };
  },
  computed: {},
  created() {},
  mounted() {},
  watch: {},
  methods: {
    init() {
      this.openFullscreen = true;
      this.tree.loading = true;
      this.$openLoading();
      let params = {
        orgId: this.projectId
      };
      this.$A.Go("get", "/safety/projectArea/tree", params).then(
        response => {
          this.$closeLoading();
          this.tree.loading = false;
          this.tree.data =
            response.body && response.body.length ? response.body : [];
        },
        err => {
          this.$closeLoading();
          this.tree.loading = false;
        }
      );
    },
    close() {
      this.openFullscreen = false;
    },
    selected(treeCurrentRow) {
      this.$emit("selectdArea", treeCurrentRow);
      this.close();
    }
  },
  destroyed() {}
};
</script>
<style lang="less">
</style>